package com.huanong.it.xwweibo.authority.common.utils;

import cn.hutool.json.JSONUtil;
import com.huanong.it.xwweibo.authority.common.entity.Result;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletUtils {
    public static void renderString(HttpServletResponse response, String string) {
        response.setContentType("application/json");
        response.setCharacterEncoding("utf-8");
        try {
            response.getWriter().print(JSONUtil.toJsonStr(Result.succ(string)));
        } catch (IOException e) {
            throw new RuntimeException(e+"渲染字符串异常");
        }
    }
}
